// Learn TypeScript:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/typescript.html
//  - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
//  - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
//  - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html

const {ccclass, property} = cc._decorator;
// 游戏级别
enum Level {
    SIMPLE,
    RUMEN,
    JINJIE,
    ZHONGJIE,
    GAOJIE,
    CHAOJIE,
    WUDI
}
import EventManager from "./managers/EventManager";
import AudioManager from "./managers/AudioManager";
@ccclass
export default class Menu extends cc.Component {

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {}

    start () {
        EventManager.getInstance().addEventListener("btnmusic",this.playmusic,this);
    }
    private playmusic(): void {
        AudioManager.getInstance().playEffect("music/sound.wav");
    }
    onDestroy(): void {
        EventManager.getInstance().removeEventListener("btnmusic",this.playmusic,this);
    }
    private btnEvent(e: cc.Event,data: any) {
        let dataNum: number = Number(data);
        switch(dataNum) {
            case -1:
                cc.director.loadScene("index");
                break;
            case Level.SIMPLE:
                console.log("简单");
                break;
            case Level.RUMEN:
                break;
            case Level.JINJIE:
                break;
            case Level.CHAOJIE:
                break;
            case Level.GAOJIE:
                break;
            case Level.CHAOJIE:
                break;
            case Level.WUDI:
                break;

        }
        EventManager.getInstance().dispatchEvent({type: "btnmusic",message: "btnmusic"});
        cc.director.loadScene("level");
    }
    // update (dt) {}
}
